package com.example.qxfw.backgroundManagement.service.impl;

import com.example.qxfw.backgroundManagement.mapper.MonitoringManagementMapper;
import com.example.qxfw.backgroundManagement.service.MonitoringManagementService;
import com.example.qxfw.common.entity.CollectTime;
import com.example.qxfw.common.entity.PublishRecord;
import com.example.qxfw.rcyw.pojo.JobMake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

/************************************
 *
 * @author : HuangDeYin Jolly
 * @since : JDK 11
 * @Date : 2023/7/3  星期一   13:59
 * @description : 此类用来
 ***************************************/
@Service
public class MonitoringManagementServiceImpl implements MonitoringManagementService {

    @Autowired
    private MonitoringManagementMapper monitoringManagementMapper;

    @Override
    public List<JobMake> selectJobType() {
        List<JobMake> jobMakes = this.monitoringManagementMapper.selectJobType();
        return jobMakes;
    }

    @Override
    public List<JobMake> selectAll() {
        return this.monitoringManagementMapper.selectAll();
    }

    @Override
    public List<JobMake> selectRecentMakeTime(final String jobType, final String makeTimeChar) {
        LocalDate now = LocalDate.now();
        int month = now.getMonthValue();
        List<JobMake> jobMakes = this.monitoringManagementMapper.selectRecentMakeTime(jobType, makeTimeChar);
        String maketimecharNew = jobMakes.get(0).getMaketimechar();
        List<JobMake> jobMakes1 = new ArrayList<>();
        if (maketimecharNew!=null){
            jobMakes1 = this.monitoringManagementMapper.selectByJobTypeAndRecentMakeTime(jobType, String.valueOf(month));
        }

        return jobMakes1;
    }



    @Override
    public List<CollectTime> selectCollectTime(final String dispName, final String collectType) {
        List<CollectTime> collectTimes = this.monitoringManagementMapper.selectCollectTime(dispName, collectType);
        return collectTimes;
    }

    @Override
    public List<PublishRecord> selectPublicRecord() {
        List<PublishRecord> publishRecords = this.monitoringManagementMapper.selectPublicRecord();
        return publishRecords;
    }

    @Override
    public Integer updateStateByType(final String type, final String state) {
        Integer update = this.monitoringManagementMapper.updateStateByType(type, state);
        return update;
    }

    @Override
    public List<JobMake> selectByJobTypeAndJobName(final String nameType, final String jobName) {
        List<JobMake> jobMakes = this.monitoringManagementMapper.selectByJobTypeAndJobName(nameType, jobName);
        return jobMakes;
    }

    @Override
    public List<PublishRecord> selectByProduceNameAndProductType(final String productName, final String productType) {
        List<PublishRecord> publishRecords = this.monitoringManagementMapper.selectByProduceNameAndProductType(productName, productType);
        return publishRecords;
    }

    @Override
    public List<JobMake> selectJobName(final String nameType) {
        return this.monitoringManagementMapper.selectJobName(nameType);
    }
}
